import tab from './tab';
import auth from './auth';
import cache from './cache';
import modal from './modal';
import download from './download';
import * as utils from '@/utils';
import { useDict } from '@/utils/dict';
import {
  addDateRange,
  handleTree,
  parseTime,
  resetForm,
  selectDictLabel,
  selectDictLabels,
} from '@/utils/ruoyi';
import type { App } from 'vue';

export function registerGlobProperties(app: App) {
  // 全局方法挂载
  app.config.globalProperties.$utils = utils;
  app.config.globalProperties.useDict = useDict;
  app.config.globalProperties.download = download.file.bind(download);
  app.config.globalProperties.parseTime = parseTime;
  app.config.globalProperties.resetForm = resetForm;
  app.config.globalProperties.handleTree = handleTree;
  app.config.globalProperties.addDateRange = addDateRange;
  app.config.globalProperties.selectDictLabel = selectDictLabel;
  app.config.globalProperties.selectDictLabels = selectDictLabels;
  // 页签操作
  app.config.globalProperties.$tab = tab;
  // 认证对象
  app.config.globalProperties.$auth = auth;
  // 缓存对象
  app.config.globalProperties.$cache = cache;
  // 模态框对象
  app.config.globalProperties.$modal = modal;
  // 下载文件
  app.config.globalProperties.$download = download.file.bind(download);
}

// 导出全部 建议直接引入 少用getCurrentInstance() 3.5版本proxy 简配了 建议使用转变使用 inject/provide方式
export { download, auth, cache, modal, utils, useDict };
